import { Injectable } from '@angular/core';
import * as _ from 'lodash';

@Injectable()
export class MonitorEchartsService {
  // 环图
  showPie(data, params) {
    console.log(data, params);
    const option = {
      title: {
        text: params.text,
        subtext: params.subtext,
        top: params.top || '20%',
        x: 'center',
        y: 'center',
        textStyle: {
          fontSize: '14',
          fontWeight: 'bold',
          color: params.textColor,
        },
        subtextStyle: {
          fontSize: '12',
          fontWeight: 'bold',
          color: params.subtextColor
        }
      },
      series: [{
        name: '环图',
        type: 'pie',
        radius: ['85%', '100%'],
        avoidLabelOverlap: true,
        hoverAnimation: false,
        data: [{
          value: 4950,
          itemStyle: {
            normal: {
              color: params.color
            }
          }
        }, {
          value: 5050,
          itemStyle: {
            normal: {
              color: params.base_color
            }
          }
        }],
        itemStyle: {
          normal: {
            label: {
              show: params.showLabel || false,
              formatter: 40 + '%',
              position: 'center',
              textStyle: {
                fontSize: 12
              }
            },
            labelLine: { show: true }
          }
        }
      }]
    };
      return option;
  }
}
